from pydantic import BaseModel, ConfigDict

from core.data_types import DatetimeStr


class Catalog(BaseModel):
    name: str
    order: int | None = None
    catalog_type: int
    related_id: int | None = None
    parent_id: int | None = None


class CatalogSimpleOut(Catalog):
    model_config = ConfigDict(from_attributes=True)

    id: int
    create_time: DatetimeStr
    update_time: DatetimeStr


class CatalogTreeListOut(CatalogSimpleOut):
    model_config = ConfigDict(from_attributes=True)

    children: list[dict] = []
